
# add NDVI as band to images
def addNDVItoL8(image):
    ndvi = image.normalizedDifference(["SR_B5","SR_B4"]);
    return image.addBands(ndvi.rename("NDVI"));


# remove clouds
def rmCloud(image):
    cloudShadowBitMask = ( 1 << 4)
    cloudsBitMask = (1 << 3)
    qa = image.select('QA_PIXEL')
    mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0).And(qa.bitwiseAnd(cloudsBitMask).eq(0))
    return image.updateMask(mask)

# see for conditional operations: https://tutorials.geemap.org/Image/conditional_operations/